package com.example.administrator.familfinalcialmanagement.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.familfinalcialmanagement.R;
import com.example.administrator.familfinalcialmanagement.util.LogUtil;

/**
 * Created by Administrator on 2019/3/26.
 */

public class BaseActivity extends FragmentActivity implements View.OnClickListener {


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    //标题栏返回调用方法
    public void setBack() {
        findViewById(R.id.topBarRelative).setVisibility(View.VISIBLE);
        findViewById(R.id.topBarRelative).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    //设置标题栏中心标题
    public void setTitleText(String str) {
        try {
            TextView text = findViewById(R.id.bar_title);
            text.setText(str);
        } catch (Exception e) {
            LogUtil.e("标题栏设置有误");
        }
    }

    //设置标题栏右侧字体（如果是文字）
    public void setRightText(String str) {
        TextView text = findViewById(R.id.rightText);
        text.setText(str);
        text.setOnClickListener(this);
    }

    //设置标题栏右侧字体颜色（如果是文字）
    public void setRightTextColor(int id) {
        TextView text = findViewById(R.id.rightText);
        text.setTextColor(this.getResources().getColor(id));
    }

    //设置标题栏右侧图片
    public void setRightImg(int id) {
        ImageView image = findViewById(R.id.rightImage);
        image.setImageResource(id);
        image.setOnClickListener(this);
    }

    //设置标题栏左侧字体（如果是文字）
    public void setLeftText(String str) {
        findViewById(R.id.topBarRelative).setVisibility(View.VISIBLE);
        findViewById(R.id.left_icon).setVisibility(View.GONE);
        TextView text = findViewById(R.id.leftTitleText);
        text.setText(str);
        text.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {

    }
}
